<?php if (($section == "comments") || ($section == "view_comments")) { ?>
<div id="comment-preview">
<h2><?php echo get_material_info($row_materials['id'],$row_materials['matType'],2); ?></h2>
<p><?php echo get_material_info($row_materials['id'],$row_materials['matType'],1); if ($row_materials['matInfo'] != "") echo $row_materials['matInfo']; ?></p>
</div>

<?php } // END if (($section == "comments") || ($section == "view_comments"))
else {	
if ($section == "proposal_materials") echo "<h3>Course Materials</h3>"; else echo "<a name='materials'></a><h2>Course Materials</h2>"; ?>
<?php if ($modal_window != "true") { ?><p><span class="icon"><img src="images/page_add.png" border="0" align="absmiddle" /></span><a id="modal_window_link" href="index.php?section=proposal_materials&amp;action=add&amp;dbTable=materials&amp;go=<?php if (strstr($section, "step")) echo "confirm"; else echo "default"; ?>&amp;view=proposal_detail&amp;cid=<?php echo $cid; ?>&amp;modal_window=true">Add Materials?</a><?php } ?>
<?php if ($totalRows_materials > 0) { 
//$version_info = explode("*",get_latest_version("materials",$cid));
?>
<table class="dataTable">
<tr>
	<th colspan="2">Type/Citation</th>
    <th width="13%" nowrap="nowrap">ID / Reviewer<br>Comments?</th>
</tr>
<?php do { 
if ($section != "comments") {
	$query_cd_comments = sprintf("SELECT * FROM comments WHERE cid='%s' AND tableName='%s' AND rid='%s'", $cid, "materials", $row_materials['id']);
	$cd_comments = mysql_query($query_cd_comments, $connection) or die(mysql_error());
	$row_cd_comments = mysql_fetch_assoc($cd_comments);
	$totalRows_cd_comments = mysql_num_rows($cd_comments);
}
?>
<tr style="background-color: <?php echo $color; ?>">
	<td width="50%">
    <?php if ($modal_window == "false") { ?>
	<div class="stacked">
    <span class="icon"><img src="images/page_edit.png" align="absmiddle" border="0"></span><a id="modal_window_link" href="index.php?section=proposal_materials&amp;action=edit&amp;go=<?php echo $go; ?>&amp;view=proposal_detail&amp;dbTable=materials&amp;cid=<?php echo $cid; ?>&amp;id=<?php echo $row_materials['id']."&amp;modal_window=true"; ?>" title="Edit the Material">Edit</a>
    </div>
    <?php } ?>
	<?php echo "<strong>".get_material_info($row_materials['id'],$row_materials['matType'],2).":</strong> ".get_material_info($row_materials['id'],$row_materials['matType'],1); if ($row_materials['matInfo'] != "") echo "<br><strong>Rationale: </strong>".$row_materials['matInfo']; ?></td>
	<td width="13%" class="data">
    <div class="stacked">
    <span class="icon"><img src="images/bin_closed.png" border="0" align="absmiddle" /></span><a href="javascript:confirmation('includes/process.inc.php?action=delete&dbTable=materials','id','<?php echo $row_materials['id']; ?>','Are you sure want to delete <?php echo $row_materials['matTitle']; ?>?')">Delete?</a>
    </div>
    </td>
 	<td class="data"><?php if (($section != "proposal_materials") && ($id == "default") && ($modal_window != "true")) { echo view_comments('materials','view_comments',$cid,$row_materials['id'],'proposal_detail',$totalRows_cd_comments,'modal');
	if ($row_user['userLevel'] <= "2") echo "<div class='stacked'><span class='icon'><img src='images/comment_add.png' align='absmiddle' border='0'></span><a id='modal_window_link' href='index.php?section=comments&amp;action=add&amp;go=".$go."&amp;view=proposal_detail&amp;dbTable=materials&amp;cid=".$cid."&amp;id=".$row_materials['id']."&amp;modal_window=true' title='Add a Comment About Materials'>Add Comment</a></div>"; } else echo "&nbsp;"; ?></td>
</tr>
<?php if ($color == $color1) { $color = $color2; } else { $color = $color1; } ?>
<?php } while ($row_materials = mysql_fetch_assoc($materials)); ?>
</table>
<?php 
	} else echo "<div class='error_msg'>There are no materials associated with this course.</div>";
} ?>